{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "489733dd",
   "metadata": {},
   "outputs": [],
   "source": [
    "goods_list = [\n",
    "    ['珍珠奶茶',7],\n",
    "    ['大杯珍珠奶茶',9.5],\n",
    "    ['桶装珍珠奶茶',18]\n",
    "]\n",
    "user_shopping_car = [\n",
    "    \n",
    "]\n",
    "Alipay = int(input(\"请输入您的账户余额：\"))\n",
    "\n",
    "while True:\n",
    "    print(\"------ 欢迎选购 请输入商品编号 -----\")\n",
    "    \n",
    "    for i in range(len(goods_list)):\n",
    "        print(\"编号：%s，名称：%s,价格：%s\"%(i,goods_list[i][0],goods_list[i][1]))\n",
    "\n",
    "choice = input(\"请正确输入购买商品的编号\")\n",
    "if choice.isdigit(): \n",
    "    choice = int(choice)\n",
    "    if choice > len(goods_list):\n",
    "        print(\"您选择的商品不存在\")\n",
    "    else:\n",
    "        if Alipay > goods_list[choice][1]:\n",
    "            user_shopping_car.append(goods_list[choice])\n",
    "            Alipay = Alipay - goods_list[choice][1]\n",
    "            print(\"【%s】已经加入了您的购物车，您的【账户余额】还有：%s 元%\"%(goods_list[choice][1]))\n",
    "        else:\n",
    "            print(\"您的余额不足，请更换支付方式\")\n",
    "elif choice == \"q\"\n",
    "    print(\"用户购物车：\",user_shopping_car)\n",
    "    print(\"您的余额还有：\",Alipay)\n",
    "    break\n",
    "else:\n",
    "    print(\"请输入【商品编号】！！或者按照输入提示进行输入\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
